<!DOCTYPE html>
<html>
<head>
    <title>机构维护页面</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript">
        var path = window.document.location.href;
        var pathName = window.document.location.pathname;
        var hostPath = path.substring(0, path.indexOf(pathName));
        var projectName = pathName.substring(0, pathName.substr(1).indexOf("/") + 1);
        document.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr' + 'ipt>');
    </script>
</head>
<body>
<table id="dg" style="width: auto; height: auto" fitColumns="true">
    <thead>
    <tr>
        <th field="id" data-options="hidden:true">ID</th>
        <th field="periods" data-options="hidden:true">期数版本</th>
        <th field="orgNo" align="right" width="100"
            data-options="
				sortable:true,
				remoteSort:false
				">机构号
        </th>
        <th field="orgName" align="right" width="100"
            data-options="
				sortable:true,
				remoteSort:false
				">机构名称
        </th>
        <th field="orgGrade" align="right" width="100"
            data-options="
				sortable:true,
				remoteSort:false
				">机构级别
        </th>
        <th field="status" align="right" width="100"
            data-options="
				sortable:true,
				remoteSort:false
				">状态
        </th>
        <th field="parentId" align="right" width="100"
            data-options="
				sortable:true,
				remoteSort:false
				">上级机构
        </th>
        <th field="orgType" data-options="hidden:true">机构类型</th>
        <th field="orgAlias" align="right" width="100"
            data-options="
				sortable:true,
				remoteSort:false
				">核心机构号
        </th>
        <th field="remark" align="right" width="100"
            data-options="
				sortable:true,
				remoteSort:false
				">备注
        </th>
        <th field="valideDate" data-options="hidden:true">生效日期</th>
        <th field="invalideDate" data-options="hidden:true">失效日期</th>
        <th field="conductUser" align="right" width="100"
            data-options="
				sortable:true,
				remoteSort:false
				">修改人
        </th>
        <th field="conductTime" align="right" width="100"
            data-options="
				sortable:true,
				remoteSort:false
				">修改时间
        </th>
    </tr>
    </thead>
</table>
<div id="dg-buttons" style="height: auto">
    <div style="margin-bottom:5px">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true"
           onclick="dlgAdd()">新增</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true"
           onclick="dlgRemove()">删除</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true"
           onclick="dlgEdit()">修改</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-excel',plain:true"
           onclick="dlgExport()">导出</a>
    </div>
    <div>
        <span>&nbsp;&nbsp;&nbsp;&nbsp;选择:</span>
        <input type="text" id="searchKey" name="searchKey" class="easyui-combobox"/>
        <span>等于:</span>
        <input type="text" id="searchValue" name="searchValue" class="easyui-validatebox"/>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="dgop.find()">查询</a>
    </div>
</div>
<div id="dlg-buttons">
    <a href="javascript:dlgSave()" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
    <a href="javascript:dlgClose()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
</div>
<div id="dlg" class="easyui-dialog" closed="true" style="width: 730px; height: 380px; padding: 10px 10px;"
     buttons="#dlg-buttons">
    <form method="post" id="fm">
        <table cellspacing="8px;">
            <td><input id="id" name="id" style="display: none"></td>
            <tr>
                <td>机构号</td>
                <td><input id="orgNo" name="orgNo" class="easyui-validatebox" required="true"
                >&nbsp;
                    <span style="color: red">*</span>
                </td>
            </tr>
            <tr>
                <td>机构名称</td>
                <td><input id="orgName" name="orgName" class="easyui-validatebox" required="true"
                >&nbsp;
                    <span style="color: red">*</span>
                </td>
            </tr>
            <tr>
                <td>机构级别</td>
                <td><input id="orgGrade" name="orgGrade" class="easyui-combobox" required="true"
                >&nbsp;
                    <span style="color: red">*</span>
                </td>
            </tr>
            <tr>
                <td>状态</td>
                <td><input id="status" name="status" class="easyui-combobox" required="true"
                >&nbsp;
                    <span style="color: red">*</span>
                </td>
            </tr>
            <tr>
                <td>上级机构</td>
                <td><input id="parentId" name="parentId" class="easyui-combobox" required="true"
                >&nbsp;
                    <span style="color: red">*</span>
                </td>
            </tr>
            <tr>
                <td>核心机构号</td>
                <td><input id="orgAlias" name="orgAlias" class="easyui-validatebox" required="true"
                >&nbsp;
                    <span style="color: red">*</span>
                </td>
            </tr>
            <tr>
                <td>备注</td>
                <td><input id="remark" name="remark" class="easyui-validatebox" required="true"
                >&nbsp;
                    <span style="color: red">*</span>
                </td>
            </tr>
        </table>
    </form>
</div>
<div id="dlg-Details" class="easyui-window" closed="true"
     style="width: 730px; height: 280px; padding: 10px 10px;"></div>

<script>
    var initd = {
        queryDataURL: "/system/orginfo/query",//查询URL
        saveDataURL: "/system/orginfo/save",//保存URL
        removeDataURL: "/system/orginfo/remove",//删除URL
        dg: $('#dg'),
        dataDicList: {
            'USER': ['conductUser'],
            'OrgGrade': ['orgGrade'],
            'ORG': ['parentId'],
            'STATUS': ['status']
        }//需加载的 DATADIC 字典名+作用的字段名
    };

    function removeOrgInfo() {
        var selectedRows = $("#dg").datagrid("getSelections");
        if (selectedRows.length == 0) {
            $.messager.alert("系统提示", "请选择要删除的数据！");
            return;
        }
        var removeData = selectedRows[0]
        if (selectedRows.length > 1) {
            removeData = {
                'deleteRows': deleteRows,
            }
        }

        var orgNo = removeData.orgNo;

        $.messager.confirm("系统提示", "您确定要删除这<font color=red>" + selectedRows.length + "</font>条数据吗？", function (r) {
            if (r) {
                $.ajax({
                    type: "DELETE",
                    dataType: "json",
                    url: projectName + "/system/orginfo/" + orgNo + "/remove",
                    beforeSend: function () {
                    },
                    success: function (result) {
                        if (result.success) {
                            $.messager.alert("系统提示", "数据已成功删除！");
                            $("#dg").datagrid("reload");
                        } else {
                            if (!jQuery.isEmptyObject(result.message)) {
                                $.messager.alert("系统错误", result.message);
                            } else {
                                $.messager.alert("系统错误", result);
                            }
                            return;
                        }
                    },
                    error: function (err, status) {
                        errorMsgAlert(err);
                        $.messager.progress("close");
                    }
                });

            }
        });
    }
</script>
</body>
</html>
